package org.tigris.atlas.examples.service;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import junit.framework.TestCase;

import org.tigris.atlas.examples.service.delegate.PrimitiveParametersExampleServiceDelegate;
import org.tigris.atlas.examples.service.delegate.ServiceDelegateFactory;
import org.tigris.atlas.service.VoidServiceResponse;

public class TestPrimitiveParametersExample extends TestCase {

	private PrimitiveParametersExampleServiceDelegate delegate;
	
	public void setUp() throws Exception {
		super.setUp();
		
		delegate = ServiceDelegateFactory.createPrimitiveParametersExampleServiceDelegate();
	}
	
	public void testString() {
		Collection items = new ArrayList();
		items.add("foo");
		items.add("bar");
		
		VoidServiceResponse response = delegate.testManyString(items);
		assertFalse(response.getMessages().hasErrorMessages());
	}
	
	public void testBigDecimal() {
		Collection items = new ArrayList();
		items.add(new BigDecimal("1.5"));
		items.add(new BigDecimal("0"));
		
		VoidServiceResponse response = delegate.testManyBigDecimal(items);
		assertFalse(response.getMessages().hasErrorMessages());
	}
	
	public void testBoolean() {
		Collection items = new ArrayList();
		items.add(Boolean.TRUE);
		items.add(Boolean.FALSE);
		
		VoidServiceResponse response = delegate.testManyBoolean(items);
		assertFalse(response.getMessages().hasErrorMessages());
	}
	
	public void testInteger() {
		Collection items = new ArrayList();
		items.add(new Integer("-1"));
		items.add(new Integer("1000"));
		
		VoidServiceResponse response = delegate.testManyInt(items);
		assertFalse(response.getMessages().hasErrorMessages());
	}
	
	public void testLong() {
		Collection items = new ArrayList();
		items.add(new Long(10000));
		items.add(new Long(1203124));
		
		VoidServiceResponse response = delegate.testManyLong(items);
		assertFalse(response.getMessages().hasErrorMessages());
	}
	
	public void testDate() {
		Collection items = new ArrayList();
		items.add(new Date());
		items.add(new Date());
		
		VoidServiceResponse response = delegate.testManyDate(items);
		assertFalse(response.getMessages().hasErrorMessages());
	}
	
	public void testTimestamp() {
		Collection items = new ArrayList();
		items.add(new Timestamp(System.currentTimeMillis()));
		items.add(new Timestamp(System.currentTimeMillis()));
		
		VoidServiceResponse response = delegate.testManyTimestamp(items);
		assertFalse(response.getMessages().hasErrorMessages());
	}
	
}
